﻿<cfsilent>
	<cfscript>
		
		dictAdvice = getProperty("serviceFactory").getBean("senateDictionaryAdvice");
		mathAdvice = getProperty("serviceFactory").getBean("senateMathAdvice");
		sessionAdvice = getProperty("serviceFactory").getBean("sessionAdvice");

		event.setArg("pageTitle", "教学运行管理 - 考试安排 - 课程考试安排分组设定");
		
		termId = event.getArg("TermID");
		depId = sessionAdvice.getUserProp("teacherDepartment");
		taskType = event.getArg("TT");
		courseId = event.getArg("CID");

		academicYear = event.getArg("AcademicYear");
		academicTerm = event.getArg("AcademicTerm");
		termDateStart = event.getArg("DateStart");

		currentTab = event.getArg("TabID", "labToArrange");

		targetArgs = structNew();
		structInsert(targetArgs, "DepID", depId);
		
		passArgs = structNew();
		structInsert(passArgs, "DepID", depId);
		structInsert(passArgs, "CID", courseId);
		structInsert(passArgs, "TT", taskType);
		
		passDelArgs = structNew();
		structInsert(passDelArgs, "DepID", depId);
		structInsert(passDelArgs, "CID", courseId);
		structInsert(passDelArgs, "TT", taskType);
		
		sql = "SELECT 
					t_course.course_name, 
					t_institute.institute_name, 
					t_course.period, 
					t_course.period_theory, 
					t_course.course_credit, 
					t_course.cid, 
					t_institute.institute_id 
				FROM  
					t_course 
					INNER JOIN t_institute ON t_institute.institute_id = t_course.institute_id 
				WHERE 
					t_course.cid = :courseId ";
					
		queryObj = new query( datasource=application.dnsSlave );
		queryObj.addParam( name="courseId", value=courseId, cfsqltype="cf_sql_varchar" );
		rs_courseEntity = queryObj.execute( sql=sql ).getResult(); 
		
		sql = "SELECT campus_id, campus_name FROM t_campus ORDER BY campus_id ";
					
		queryObj = new query( datasource=application.dnsSlave );
		rs_campus = queryObj.execute( sql=sql ).getResult(); 
			
		/* 读取现有的考试安排任务 */
		sql = "SELECT 
					t_course.course_name, 
					t_examtask.exidx, 
					t_examtask.wid, 
					t_campus.campus_name,
					t_examtask.wdidx, 
					t_examtask.cellidx, 
					t_examtask.task_exid 
				FROM 
					t_examtask 
					INNER JOIN t_course ON t_course.cid = t_examtask.cid 
					INNER JOIN t_campus ON t_campus.campus_id = t_examtask.campus_id 
				WHERE 
					t_examtask.term_id = :termId 
					AND 
					t_examtask.exam_type = 'F' 
					AND 
					t_course.cid = :courseId 
				ORDER BY 
					t_examtask.exidx ";
					
		queryObj = new query( datasource=application.dnsSlave );
		queryObj.addParam( name="termId", value=termId, cfsqltype="cf_sql_char" );
		queryObj.addParam( name="courseId", value=courseId, cfsqltype="cf_sql_varchar" );
		rs_exam = queryObj.execute( sql=sql ).getResult();
		

		/* 读取尚为安排考试教学班详细数据 */
		switch ( taskType ) {
			
			case "P":
				sql = "SELECT 
							a.tsk_id, 
							a.cidx, 
							t_campus.campus_name, 
							t_teacher.tch_name, 
							a.task_week, 
							a.task_chooesd, 
							a.task_classes task_classes, 
							a.campus_id, 
							t_course.course_name 
						FROM 
							t_task a 
							INNER JOIN t_campus ON t_campus.campus_id = a.campus_id 
							INNER JOIN t_teacher ON t_teacher.tch_id = a.tch_id 
							INNER JOIN t_course ON t_course.cid = a.cid 
						WHERE 
							a.term_id = :termId 
							AND 
							a.cid = :courseId 
							AND 
							EXISTS(
								  SELECT 1 FROM t_examplan b 
								  WHERE b.task_id = a.tsk_id AND b.is_arrange = '0'
							)
						ORDER BY 
							t_campus.campus_name, t_teacher.tch_name, a.cidx";
							
				queryObj = new query( datasource=application.dnsSlave );			
				queryObj.addParam( name="termId", value=termId, cfsqltype="cf_sql_char" );
				queryObj.addParam( name="courseId", value=courseId, cfsqltype="cf_sql_varchar" );
				rs_task = queryObj.execute( sql=sql ).getResult();
				
				sql = "SELECT 
							a.tsk_id, 
							a.cidx, 
							t_campus.campus_name, 
							t_teacher.tch_name, 
							a.task_week, 
							a.task_chooesd, 
							a.task_classes task_classes, 
							a.campus_id, 
							t_course.course_name 
						FROM 
							t_task a 
							INNER JOIN t_campus ON t_campus.campus_id = a.campus_id 
							INNER JOIN t_teacher ON t_teacher.tch_id = a.tch_id 
							INNER JOIN t_course ON t_course.cid = a.cid 
						WHERE 
							a.term_id = :termId 
							AND 
							a.cid = :courseId 
							AND 
							EXISTS(
								  SELECT 1 FROM t_examplan b 
								  WHERE b.task_id = a.tsk_id AND b.is_arrange = 'N'
							)
						ORDER BY 
							t_campus.campus_name, t_teacher.tch_name, a.cidx";
							
				queryObj = new query( datasource=application.dnsSlave );			
				queryObj.addParam( name="termId", value=termId, cfsqltype="cf_sql_char" );
				queryObj.addParam( name="courseId", value=courseId, cfsqltype="cf_sql_varchar" );
				rs_taskRestore = queryObj.execute( sql=sql ).getResult();
				
				sql = "SELECT 
							a.tsk_id, 
							a.cidx, 
							t_campus.campus_name, 
							t_teacher.tch_name, 
							a.task_week, 
							a.task_chooesd, 
							'-' task_classes, 
							a.campus_id, 
							t_course.course_name 
						FROM 
							t_reopen_task a 
							INNER JOIN t_campus ON t_campus.campus_id = a.campus_id 
							INNER JOIN t_teacher ON t_teacher.tch_id = a.tch_id 
							INNER JOIN t_course ON t_course.cid = a.cid 
						WHERE 
							a.term_id = :termId 
							AND 
							a.cid = :courseId 
							AND 
							EXISTS(
								  SELECT 1 FROM t_examplan b 
								  WHERE b.task_id = a.tsk_id AND b.is_arrange = '0'
							)
						ORDER BY 
							t_campus.campus_name, t_teacher.tch_name, a.cidx";
							
				queryObj = new query( datasource=application.dnsSlave );			
				queryObj.addParam( name="termId", value=termId, cfsqltype="cf_sql_char" );
				queryObj.addParam( name="courseId", value=courseId, cfsqltype="cf_sql_varchar" );
				rs_taskOpen = queryObj.execute( sql=sql ).getResult();
				
				break;

			case "C":
				sql = "SELECT 
							a.tsk_id, 
							a.cidx, 
							t_campus.campus_name, 
							t_teacher.tch_name, 
							a.task_week, 
							a.task_chooesd, 
							'-' task_classes, 
							a.campus_id, 
							t_course.course_name 
						FROM 
							t_common_task a 
							INNER JOIN t_campus ON t_campus.campus_id = a.campus_id 
							INNER JOIN t_teacher ON t_teacher.tch_id = a.tch_id 
							INNER JOIN t_course ON t_course.cid = a.cid 
						WHERE 
							a.term_id = :termId 
							AND 
							a.cid = :courseId 
							AND 
							EXISTS(
								  SELECT 1 FROM t_examplan b 
								  WHERE b.task_id = a.tsk_id AND b.is_arrange = '0'
							)
						ORDER BY 
							t_campus.campus_name, t_teacher.tch_name, a.cidx";
							
				queryObj = new query( datasource=application.dnsSlave );			
				queryObj.addParam( name="termId", value=termId, cfsqltype="cf_sql_char" );
				queryObj.addParam( name="courseId", value=courseId, cfsqltype="cf_sql_varchar" );
				rs_task = queryObj.execute( sql=sql ).getResult();
				
				
				sql = "SELECT 
							a.tsk_id, 
							a.cidx, 
							t_campus.campus_name, 
							t_teacher.tch_name, 
							a.task_week, 
							a.task_chooesd, 
							'-' task_classes, 
							a.campus_id, 
							t_course.course_name 
						FROM 
							t_common_task a 
							INNER JOIN t_campus ON t_campus.campus_id = a.campus_id 
							INNER JOIN t_teacher ON t_teacher.tch_id = a.tch_id 
							INNER JOIN t_course ON t_course.cid = a.cid 
						WHERE 
							a.term_id = :termId 
							AND 
							a.cid = :courseId 
							AND 
							EXISTS(
								  SELECT 1 FROM t_examplan b 
								  WHERE b.task_id = a.tsk_id AND b.is_arrange = 'N'
							)
						ORDER BY 
							t_campus.campus_name, t_teacher.tch_name, a.cidx";
							
				queryObj = new query( datasource=application.dnsSlave );			
				queryObj.addParam( name="termId", value=termId, cfsqltype="cf_sql_char" );
				queryObj.addParam( name="courseId", value=courseId, cfsqltype="cf_sql_varchar" );
				rs_taskRestore = queryObj.execute( sql=sql ).getResult();
				
				break;
			case "R":
				sql = "SELECT 
							a.tsk_id, 
							a.cidx, 
							t_campus.campus_name, 
							t_teacher.tch_name, 
							a.task_week, 
							a.task_chooesd, 
							'-' task_classes, 
							a.campus_id, 
							t_course.course_name 
						FROM 
							t_reopen_task a 
							INNER JOIN t_campus ON t_campus.campus_id = a.campus_id 
							INNER JOIN t_teacher ON t_teacher.tch_id = a.tch_id 
							INNER JOIN t_course ON t_course.cid = a.cid 
						WHERE 
							a.term_id = :termId 
							AND 
							a.cid = :courseId 
							AND 
							EXISTS(
								  SELECT 1 FROM t_examplan b 
								  WHERE b.task_id = a.tsk_id AND b.is_arrange = '0'
							)
						ORDER BY 
							t_campus.campus_name, t_teacher.tch_name, a.cidx";
							
				queryObj = new query( datasource=application.dnsSlave );			
				queryObj.addParam( name="termId", value=termId, cfsqltype="cf_sql_char" );
				queryObj.addParam( name="courseId", value=courseId, cfsqltype="cf_sql_varchar" );
				rs_task = queryObj.execute( sql=sql ).getResult();
				
				
				sql = "SELECT 
							a.tsk_id, 
							a.cidx, 
							t_campus.campus_name, 
							t_teacher.tch_name, 
							a.task_week, 
							a.task_chooesd, 
							'-' task_classes, 
							a.campus_id, 
							t_course.course_name 
						FROM 
							t_reopen_task a 
							INNER JOIN t_campus ON t_campus.campus_id = a.campus_id 
							INNER JOIN t_teacher ON t_teacher.tch_id = a.tch_id 
							INNER JOIN t_course ON t_course.cid = a.cid 
						WHERE 
							a.term_id = :termId 
							AND 
							a.cid = :courseId 
							AND 
							EXISTS(
								  SELECT 1 FROM t_examplan b 
								  WHERE b.task_id = a.tsk_id AND b.is_arrange = 'N'
							)
						ORDER BY 
							t_campus.campus_name, t_teacher.tch_name, a.cidx";
							
				queryObj = new query( datasource=application.dnsSlave );			
				queryObj.addParam( name="termId", value=termId, cfsqltype="cf_sql_char" );
				queryObj.addParam( name="courseId", value=courseId, cfsqltype="cf_sql_varchar" );
				rs_taskRestore = queryObj.execute( sql=sql ).getResult();
				
				break;
			
		}
		
		taskIds = "";
		taskEndArray = [];
		
		campusQuery = queryNew("CampusID", "VarChar");
		
		//for ( task in taskArray ) {
		for ( i=1; i LTE rs_task.recordCount; i++){
			
			/* 设置默认的教学班考试合班 */
			taskIds = listAppend(taskIds, rs_task["tsk_id"][i], "|");
			
			/* 计算最晚和最早的考试结束周次 */
			taskEnd = 1 * listLast(rs_task["task_week"][i], "-");
			
			if ( not arrayFind(taskEndArray, taskEnd) ) {
				arrayAppend(taskEndArray, taskEnd);
			}
			
			/* 生成校区查询 */
			queryAddRow(campusQuery, 1);
			querySetCell(campusQuery, "CampusID", rs_task["campus_id"][i]);
		}
		
		
		/* 更新显示标签逻辑 */
		if ( currentTab eq "labToArrange" and rs_task.recordCount eq 0 and rs_taskRestore.recordCount gt 0 ) {
			currentTab = "labNoArrange";
		}

	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('examPlan')#</cfoutput>"><i class="mrs img btnList"></i><span class="uiButtonText">学院课程考试安排</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 campus"></i>课程考试方式设置
				</h2>
			</div>
		</div>
	</div>
</div>

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix">
			
				<div class="UItab">
					<div class="tabLables">
						<span <cfif currentTab eq "labToArrange">class="active"</cfif> id="labToArrange" tabTarget="ToArrange">课程考试安排</span>
						<cfif rs_taskRestore.recordCount>
							<span <cfif currentTab eq "labNoArrange">class="active"</cfif> id="labNoArrange" tabTarget="NoArrange">不安排考试任务</span>
						</cfif>
						<cfif rs_exam.recordCount>
							<span <cfif currentTab eq "labDoneArrange">class="active"</cfif> id="labDoneArrange" tabTarget="DoneArrange">考试周次及分组</span>
						</cfif>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					// -->
					//]]>
				</script>
				
				<div id="ToArrange" class="tabContent">
					
					<div class="noticeBlock">
						<div class="operation">
						</div>
						<h3>《<cfoutput>#rs_courseEntity.course_name#</cfoutput>》 任课单位: <cfoutput>#rs_courseEntity.institute_name#</cfoutput></h3>
						<p><span class="img icon16x16 message"></span>总学时 <em><cfoutput>#rs_courseEntity.period#</cfoutput></em>, 其中理论学时 <em><cfoutput>#rs_courseEntity.period_theory#</cfoutput></em>. 课程总学分:<em><cfoutput>#numberFormat(rs_courseEntity.course_credit, '_.00')#</cfoutput></em> 在<em><cfoutput>#academicYear#</cfoutput>-<cfoutput>#academicTerm#</cfoutput></em>学期, 该课程尚有<em><cfoutput>#rs_task.recordCount#</cfoutput></em>个教学班未安排考试</p>
					</div>
					
					<div id="formBox" class="hidden_elem">
						
						<cfif rs_task.recordCount>

							<form id="formCreate" class="formWrapper" method="post" action="<cfoutput>#buildURL('examTaskCreateDo')#</cfoutput>">
							
								<input type="hidden" name="CourseID" value="<cfoutput>#rs_courseEntity.cid#</cfoutput>" />
								<input type="hidden" name="TermID" value="<cfoutput>#termId#</cfoutput>" />
							
								<input type="hidden" id="TaskClassIDs" name="TaskClassIDs" value="<cfoutput>#taskIds#</cfoutput>" />
								
								<!--- PASSED ARGS --->
								<input type="hidden" name="InstituteID" value="<cfoutput>#rs_courseEntity.institute_id#</cfoutput>" />
								<input type="hidden" name="TaskType" value="<cfoutput>#taskType#</cfoutput>" />
								
								<div class="label">
									<span class="req">*</span><b>已选教学任务</b>
									<div id="TaskClassNames" class="secondRow"></div>
								</div>
								
								<!--- 设置最适合的校区 --->
								<cfquery name="campusSuggest" dbtype="query">
									SELECT CampusID, COUNT(*) TaskCount
									FROM campusQuery
									GROUP BY CampusID
									ORDER BY TaskCount DESC
								</cfquery>
								
								<div class="label">
									<b>考试校区</b>
									<select name="CampusID" id="CampusID">
                                        <cfloop query="rs_campus">
											<option <cfif campusSuggest.CampusID eq rs_campus.campus_id>selected="selected"</cfif> value="<cfoutput>#rs_campus.campus_id#</cfoutput>"><cfoutput>#rs_campus.campus_name#</cfoutput></option>
										</cfloop>
									</select>
								</div>
								
								<cfset arraySort(taskEndArray, "numeric", "asc") />
								<!--- /* 该门课程授课 最早什么时候结束 */ --->
								<cfset taskEndMin = taskEndArray[1] />
								<!--- /* 该门课程授课 最晚什么时候结束 */ --->
								<cfset taskEndMax = taskEndArray[arrayLen(taskEndArray)] />
								
								<!--- /* 计算当前教学周 */ --->
								<cfset nextTaskWeek = mathAdvice.convertTaskWeek(termDateStart, DateFormat(now(), "YYYYMMDD")) + 1 />
								<!--- /* 安排考试只能从下周开始 */ --->
								<cfif nextTaskWeek gt taskEndMin>
									<cfset taskEndMin = nextTaskWeek />
								</cfif>

								<div class="label">
									<b>考试周次</b>
									<select name="WID" id="WID">
										<cfloop from="#taskEndMin#" to="22" index="wid">
											<option <cfif taskEndMax+2 eq wid>selected="selected"</cfif> value="<cfoutput>#numberFormat(wid, '0_')#</cfoutput>">第<cfoutput>#wid#</cfoutput>周</option>
										</cfloop>
									</select>
								</div>
								
								<hr/>
							
								<div class="lable">
									<input class="button" type="submit" value="建立考试任务" />
									<input id="formReset" class="button1" type="button" value="返回" />
								</div>
								
							</form>
							
							<script language="javascript" type="text/javascript">
								//<![CDATA[
								<!--
								$(document).ready(function() {
								
									$("#formReset").click(function(){
									
										$("#taskBox").removeClass("hidden_elem");
										$("#formBox").addClass("hidden_elem");
									
									});
									
								});
								// -->
								//]]>
							</script>
							
						</cfif>
						
					</div>
					
					<div id="taskBox">
						
						<cfif rs_task.recordCount>
							<cfset row = 0 />
							
							<div class="uiOperationBox">
								<a id="opCreate" href="javascript:void(0);" class="uiOperationButton"><i class="btn execute"></i><span class="btnText">创建考试安排</span></a>
							</div>
							
							<table id="taskList" class="UIEditable">
								<thead>
									<tr>
										<td width="18"></td>
										<td width="50">课序号</td>
										<td width="70">课程类别</td>
										<td class="hidden_elem">教学班</td>
										<td width="60">上课校区</td>
										<td width="50">上课周次</td>
										<td width="50">选课人数</td>
										<td width="110">任课教师</td>
										<td>行政班</td>
										<td width="18"></td>
									</tr>
								</thead>
								<tbody>
                                    <cfloop query="rs_task">
										
										<cfset row++ />
										<cfset structInsert(passArgs, "TaskID", rs_task.tsk_id, true) />
										
										<tr class="editRows" rowid="<cfoutput>#rs_task.tsk_id#</cfoutput>">
											<td><a rowid="<cfoutput>#rs_task.tsk_id#</cfoutput>" usage="ForTask" class="stat yes"></a></td>
											<td class="index"><cfoutput>#rs_task.cidx#</cfoutput></td>
											<td class="hidden_elem"><span usage="ForTaskClassNames"><cfoutput>#rs_task.course_name#</cfoutput>-<cfoutput>#rs_task.tch_name#</cfoutput>-<cfoutput>#rs_task.cidx#</cfoutput></span></td>
											<td><cfif taskType eq 'P'>计划课程<cfelseif taskType eq 'R'>单开班<cfelseif taskType eq 'C'>全校通选</cfif></td>
											<td><cfoutput>#rs_task.campus_name#</cfoutput></td>
											<td><span class="numeric"><cfoutput>#rs_task.task_week#</cfoutput></span></td>
											<td><span class="numeric"><cfoutput>#rs_task.task_chooesd#</cfoutput></span></td>
											<td><cfoutput>#rs_task.tch_name#</cfoutput></td>
											<td><cfif rs_task.task_classes eq "-">全校<cfelse><cfoutput>#rs_task.task_classes#</cfoutput></cfif></td>
											<td><a title="该教学班不考试" href="<cfoutput>#buildURL('examCourseTaskRemoveDo', passArgs)#</cfoutput>" class="stat remove"></a></td>
										</tr>
									</cfloop>
								<cfif taskType eq 'P' and rs_taskOpen.recordCount gt 0>
                                
                                    <cfloop query="rs_taskOpen">
										
										<cfset row++ />
										<cfset structInsert(passArgs, "TaskID", rs_task.tsk_id, true) />
										<cfset structInsert(passArgs, "TT", 'R', true) />
										
										<tr class="editRows" rowid="<cfoutput>#rs_task.tsk_id#</cfoutput>">
											<td><a rowid="<cfoutput>#rs_task.tsk_id#</cfoutput>" usage="ForTask" class="stat yes"></a></td>
											<td class="index"><cfoutput>#rs_task.cidx#</cfoutput></td>
											<td class="hidden_elem"><span usage="ForTaskClassNames"><cfoutput>#rs_task.course_name#</cfoutput>-<cfoutput>#rs_task.tch_name#</cfoutput>-<cfoutput>#rs_task.cidx#</cfoutput></span></td>
											<td>单开班</td>
											<td><cfoutput>#rs_task.campus_name#</cfoutput></td>
											<td><span class="numeric"><cfoutput>#rs_task.task_week#</cfoutput></span></td>
											<td><span class="numeric"><cfoutput>#rs_task.task_chooesd#</cfoutput></span></td>
											<td><cfoutput>#rs_task.tch_name#</cfoutput></td>
											<td><cfif rs_task.task_classes eq "-">全校<cfelse><cfoutput>#rs_task.task_classes#</cfoutput></cfif></td>
											<td><a title="该教学班不考试" href="<cfoutput>#buildURL('examCourseTaskRemoveDo', passArgs)#</cfoutput>" class="stat remove"></a></td>
										</tr>
									</cfloop>
								</cfif>
								</tbody>
							</table>
							<script language="javascript" type="text/javascript">
								//<![CDATA[
								<!--
								$(document).ready(function() {
									
									$("#opCreate").click(function(){
										
										var $taskSelected = $("a.yes[usage='ForTask']");
										var taskIds = [];
										var taskclassNames = [];
										
										$taskSelected.each(function(){
											
											taskIds.push( $(this).attr("rowid") );
											
											var $tr = $("tr[rowid='" + $(this).attr("rowid") + "']");
											
											taskclassNames.push( $("span[usage='ForTaskClassNames']", $tr).text() );
											
										});
										
										
										if (taskIds.length) {

											$("#TaskClassIDs").val( taskIds.join("|") );
											$("#TaskClassNames").text( taskclassNames.join(", ") );
											
											$("#taskBox").addClass("hidden_elem");
											$("#formBox").removeClass("hidden_elem");
											
										}
										else {
											alert("请至少选择一个教学班");
										}
										
										
									});
									
									
									$("a[usage='ForTask']", $("#taskList")).click(function(){
										
										var rowid = $(this).attr("rowid");
										var status = $(this).hasClass("yes");
										
										var $tr = $("tr[rowid='" + $(this).attr("rowid") + "']");

										/* 切换状态数据 */
										if (status) {
											$(this).removeClass("yes").addClass("no");
										}
										else {
											$(this).removeClass("no").addClass("yes");
										}

									});
									
								});
								// -->
								//]]>				
							</script>
							
							
						<cfelse>
							
							<!--- 查找该学院的下一门课程 --->
                            <cfset sql = "SELECT 
											  t_course.cid, 
											  t_course.course_name, 
											  t_course.course_credit, 
											  t_examplan.task_type                         
										  FROM 
											  t_examplan 
											  INNER JOIN t_course ON t_course.cid = t_examplan.cid 
										  WHERE 
											  t_examplan.term_id = :termId 
											  AND 
											  t_course.institute_id = :depId 
											  AND 
											  (t_examplan.is_arrange = '0' )
										  GROUP BY 
											  t_course.cid, 
											  t_course.course_name, 
											  t_course.course_credit, 
											  t_examplan.task_type 										   
										  ORDER BY 
											  t_course.course_name" />
     
                            <cfset queryObj = new query( datasource=application.dnsSlave, maxRows=1 ) />
                            <cfset queryObj.addParam( name="termId", value=termId, cfsqltype="cf_sql_char" ) />
                            <cfset queryObj.addParam( name="depId", value=depId, cfsqltype="cf_sql_varchar" ) />
                            <cfset rs_courseDepLeft = queryObj.execute( sql=sql ).getResult() />
                    
        
		
							<div class="noticeBlock">
								<h3>课程安排完毕</h3>
								<p><span class="img icon16x16 message"></span>当前学期该门课程的所有考试任务已设置完毕</p>
								<ol>
									<cfif rs_courseDepLeft.recordCount>
										<li class="friendly"><span class="img icon10x10 browser"></span><a href="<cfoutput>#buildURL('examByCourse', {CID=rs_courseDepLeft.cid, TT=rs_courseDepLeft.task_type, DepID=depId})#</cfoutput>">继续处理该部门的下一门课程: 《<cfoutput>#rs_courseDepLeft.course_name#</cfoutput>》 学分: <cfoutput>#numberFormat(rs_courseDepLeft.course_credit, "_.00")#</cfoutput></a></li>
									</cfif>
								</ol>
							</div>
							
						</cfif>
						
					</div>
					
				</div>
				
				
				<cfif rs_taskRestore.recordCount>
					
					<div id="NoArrange" class="tabContent">
						
						<div class="noticeBlock">
							<h3>不安排考试教学任务</h3>
							<p><span class="img icon16x16 message"></span><em><cfoutput>#academicYear#</cfoutput>-<cfoutput>#academicTerm#</cfoutput></em>学期, 有<em><cfoutput>#rs_taskRestore.recordCount#</cfoutput></em>个教学班已标注为不需要安排考试时间</p>
							<hr/>
						</div>
						
						<cfset row = 0 />

						<table class="UIEditable">
							<thead>
								<tr>
									<td width="18"></td>
									<td width="50">课序号</td>
									<td class="hidden_elem">教学班</td>
									<td width="60">上课校区</td>
									<td width="50">上课周次</td>
									<td width="50">选课人数</td>
									<td width="110">任课教师</td>
									<td>行政班</td>
									<td width="18"></td>
								</tr>
							</thead>
							<tbody>
                                <cfloop query="rs_taskRestore">
										
									<cfset row++ />
									<cfset structInsert(passArgs, "TaskID", rs_taskRestore.tsk_id, true) />
									
									<tr class="editRows" rowid="<cfoutput>#rs_taskRestore.tsk_id#</cfoutput>">
										<td class="index"><cfoutput>#row#</cfoutput></td>
										<td class="index"><cfoutput>#rs_taskRestore.cidx#</cfoutput></td>
										<td class="hidden_elem"><span usage="ForTaskClassNames"><cfoutput>#rs_taskRestore.course_name#</cfoutput>-<cfoutput>#rs_taskRestore.tch_name#</cfoutput>-<cfoutput>#rs_taskRestore.cidx#</cfoutput></span></td>
										<td><cfoutput>#rs_taskRestore.campus_name#</cfoutput></td>
										<td><span class="numeric"><cfoutput>#rs_taskRestore.task_week#</cfoutput></span></td>
										<td><span class="numeric"><cfoutput>#rs_taskRestore.task_chooesd#</cfoutput></span></td>
										<td><cfoutput>#rs_taskRestore.tch_name#</cfoutput></td>
										<td><cfif rs_taskRestore.task_classes eq "-">全校<cfelse><cfoutput>#rs_taskRestore.task_classes#</cfoutput></cfif></td>
										<td><a title="恢复该教学班课程考试安排" href="<cfoutput>#buildURL('examCourseTaskRestoreDo', passArgs)#</cfoutput>" class="stat restore"></a></td>
									</tr>
								</cfloop>
							</tbody>
						</table>
						
					</div>
					
				</cfif>
				
				<cfif rs_exam.recordCount>
					
					<div id="DoneArrange" class="tabContent">
						
						<div class="noticeBlock">
							<h3>课程考试周次及分组安排</h3>
							<p><span class="img icon16x16 message"></span><em><cfoutput>#academicYear#</cfoutput>-<cfoutput>#academicTerm#</cfoutput></em>学期, 有<em><cfoutput>#rs_exam.recordCount#</cfoutput></em>场考试安排</p>
							<hr/>
						</div>
						
						<cfset row = 0 />
						<table class="UIEditable">
							<thead>
								<tr>
									<td width="40">场次</td>
									<td>课程</td>
									<td width="60">考试校区</td>
									<td width="50">考试周</td>
									<td>考试时间</td>
									<td width="18"></td>
								</tr>
							</thead>
							<tbody>
                                <cfloop query="rs_exam">
                                
									<cfset row++ />
									<cfset structInsert(passDelArgs, "TaskExamID", rs_exam.task_exid, true) />
									
									<tr class="editRows">
										<td class="index"><cfoutput>#rs_exam.exidx#</cfoutput></td>
										<td><cfoutput>#rs_exam.course_name#</cfoutput></td>
										<td><cfoutput>#rs_exam.campus_name#</cfoutput></td>
										<td align="center"><span class="numeric"><cfoutput>#rs_exam.wid#</cfoutput></span></td>
										<td><cfif rs_exam.wdidx eq "0">-/-<cfelse>星期<span class="numeric"><cfoutput>#rs_exam.wdidx#</cfoutput></span>第<span class="numeric"><cfoutput>#rs_exam.cellidx#</cfoutput></span>场</cfif></td>
										<td>
											<cfif rs_exam.wdidx eq "0">
												<a title="删除考试任务" href="<cfoutput>#buildURL('examTaskByCourseRemoveDo', passDelArgs)#</cfoutput>" class="stat delete"></a>
											</cfif>
										</td>
									</tr>
								</cfloop>
							</tbody>
						</table>
						
					</div>
					
				</cfif>
				
			</div>
		</li>
	</ul>
</div>